<%--
  Created by IntelliJ IDEA.
  User: 86158
  Date: 2020/7/28
  Time: 20:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <!--注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的-->
    <style>
        .client-input {
            width: 80%;
        }

        #save-client {
            margin-top: 15px;
        }
    </style>
</head>
<body>
<%--<form id="save-client" class="layui-form" action="/BYSSM_war_exploded/addcustomer">--%>
<form id="save-client" class="layui-form" lay-filter="example">
    <div class="layui-form-item">
        <label class="layui-form-label">应用AID</label>
        <div class="layui-input-block">
            <input type="text" name="aid" required  lay-verify="required" placeholder="请输入应用id" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">企业名称</label>
        <div class="layui-input-block">
            <input type="text" name="acorpName" required  lay-verify="required" placeholder="请输入企业名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">应用名称</label>
        <div class="layui-input-block">
            <input type="text" name="aappName" required  lay-verify="required" placeholder="请输入应用名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">应用唯一标示</label>
        <div class="layui-input-block">
            <input type="text" name="aappKey" required  lay-verify="required" placeholder="请输入应用唯一标示" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">应用签名秘钥</label>
        <div class="layui-input-block">
            <input type="text" name="aaa" required  lay-verify="required" placeholder="请输入应用签名秘钥" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">应用回调用URL</label>
        <div class="layui-input-inline">
            <input type="text" name="aredirectUrl" required lay-verify="required" placeholder="应用回调用URL" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">免费接口日调用次数</label>
        <div class="layui-input-block">
            <input type="text" name="alinit" required  lay-verify="money" placeholder="请输入免费接口日调用次数" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">应用介绍</label>
        <div class="layui-input-block">
            <input type="text" name="adescription" required  lay-verify="required"
                   lay-reqText="应用介绍不能为空。"
                   placeholder="请输入应用介绍" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">管理客户id</label>
        <div class="layui-input-block">
            <input type="text" name="acusid" required  lay-verify="money" placeholder="管理客户id" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="astate" value="1" title="正常">
            <input type="radio" name="astate" value="0" title="停用" checked="">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="save-btn" class="layui-btn" type="submit" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="https://cdn.bootcdn.net/ajax/libs/layui/2.5.6/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery', 'layer'], function () {
        var form = layui.form
            , $ = layui.jquery
            , layer = layui.layer
        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 5) {
                    return '账号至少得5个字符';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , money: function (value) {
                if (value < 0)
                    return '账户金额只能为正数。';
            }
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
            console.log(data.field);

            $.post("/BYSSM_war_exploded/addAppliction", {
                aid:data.field.aid,
                acorpName:data.field.acorpName,
                aappName:data.field.aappName,
                aappKey:data.field.aappKey,
                aaa:data.field.aaa,
                alinit:data.field.alinit,
                adescription:data.field.adescription,
                acusid:data.field.acusid,
                astate:data.field.astate,
                aredirectUrl:data.field.aredirectUrl
            }, function (res) {
                if (res == "success") {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    setTimeout(function () { parent.layer.close(index) }, 100);//延迟
                }
            });
            return false;
        });
    });
</script>

</body>
</html>